package com.example.sr.ip;

import org.junit.Test;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class IP {


    @Test
    public void test1() throws UnknownHostException {

        InetAddress address = InetAddress.getLocalHost();
        System.out.println("本机地址"+address);
        System.out.println("主机名:"+address.getHostName());//主机名
        System.out.println("主机别名:"+address.getCanonicalHostName());//主机别名

    }
}
